FROM golang:1.16-alpine3.13 AS builder

WORKDIR /app

RUN apk add --no-cache gcc make libc-dev git

RUN go env -w GOPROXY="https://goproxy.cn,direct"

COPY ["go.mod", "go.sum", "./"]
RUN go mod download -x

COPY . .
RUN make build

FROM alpine:latest
WORKDIR /app

COPY --from=builder /app/bin/news ./bin/
COPY --from=builder /app/docs/configs/config.yaml ./
EXPOSE 8080

ENTRYPOINT ["./bin/news"]